package  app
{
	import com.temple.core.CoreMovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author hungconcon
	 */
	public class Slide extends CoreMovieClip 
	{
		public var s1:CoreMovieClip = new CoreMovieClip();
		public var s2:CoreMovieClip = new CoreMovieClip();
		public var s3:CoreMovieClip = new CoreMovieClip();
		
		private var isCompleteShoot:Boolean = true;
		private var ball:BallFactory;
		private var court:Court;
		private var player:Player;
		
		public function Slide() 
		{
			super();
			
			court 	= new Court();
			player 	= new Player();
			ball 	= new BallFactory();
			
			addChild(s1);
			addChild(s2);
			addChild(s3);
			
			
			s1.addChild(court);
			s2.addChild(player);
			s3.addChild(ball);
			
			
			App.ballFactory = ball;
			
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		private function init(evt:Event):void {
			player.addEventListener(App.ACTIVE_SHOOT_OUT, onEvent)
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			ball.createTest(200,20);
		}
		
		private function onEvent(evt:Event):void {
			isCompleteShoot = true;
			ball.onShoot();
		}
		private function onMouseDown(evt:MouseEvent):void {
			//if (!isCompleteShoot) return;
			if(App.hold){
				player.onShoot();
				isCompleteShoot = false;
			}
		}
		
	}

}